from selenium import webdriver
from time import sleep

# 声明浏览器
broswer = webdriver.Chrome()

# 打开浏览器
broswer.get('https://www.rabbitpre.com/')
broswer.maximize_window()
# 找到登录按钮并点击操作
Sin_button = broswer.find_element_by_css_selector('#g-j-signin-btn').click()
sleep(2)
# 找到对应元素并操作
broswer.switch_to.frame('sso')
Login_button = broswer.find_element_by_css_selector('span[data-type="tuzhan"]').click()
sleep(1)
user_name = broswer.find_element_by_css_selector('[placeholder="请输入你的登录账户"]').send_keys('xxx')
sleep(1)
Pass_word = broswer.find_element_by_css_selector('[placeholder="请输入密码"]').send_keys('xxx')
sleep(1)
Confirm_button = broswer.find_element_by_css_selector('button.g-btn.login-btn.do-btn').click()
sleep(2)
# 点击新建作品
new_opus = broswer.find_element_by_css_selector('a.navbar-addTemplate-btn').click()
sleep(1)
# 切换至新页面
broswer.switch_to.window(broswer.window_handles[-1])
sleep(1)

# 创建空白模板
broswer.find_element_by_css_selector('div.create-icon').click()
broswer.switch_to.window(broswer.window_handles[-1])
sleep(1)
broswer.find_element_by_css_selector('button.g-btn.primary.icon-btn.publish').click()
sleep(2)

broswer.switch_to.window(broswer.window_handles[-1])
sleep(1)
broswer.find_element_by_xpath('//*[@id="popup-setting-container"]/div[1]/ul[2]/li[1]/div/div/div[6]/div[4]/button[2]').click()
sleep(2)
broswer.find_element_by_xpath('//*[@id="popup-setting-container"]/div[2]').click()
sleep(2)
broswer.close()
# 关闭浏览器
broswer.quit()


